<style>
	#artikul {width: 165px;}
	#days_end {width: 125px;}
	#name {width: 400px;}
	#brand_id {width: 400px;}
</style>

<?php

$peer = OrdersPeer::getInstance();
$id = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
$order = $peer->find($id)->current();
if (!$order) $order = OrdersPeer::getInstance()->createRow();


$form = $this->element;

/* @var $productRow ProductRow */
if ($form->getRow()) {
	$productRow = $form->getRow()->getRow();
} else {
	$productRow = ProductPeer::getInstance()->createRow();
}

foreach ($form->getElements() as $e) {
	if ($e instanceof Zend_Form_Element_Checkbox) {
		$label = $e->getDecorator('Label');
		$label->setOption('placement', Zend_Form_Decorator_Abstract::APPEND);
		$label->setTag('dd');

		$tag = $e->getDecorator('HtmlTag');
		$tag->setTag('dt');
		//$e->removeDecorator('Label');
		//$e->addDecorator($label);

		//echo '<pre>';
		//var_dump($e->getDecorators());die();
	}
}

function getMonthsByAge($yearsByMonth, $currentMonth = '') {
	$str = '';
	$helper = new Helpers_PluralMonths();
	for ($month = 0, $year = 1; $month < $yearsByMonth;) {
		if ($month < 23) {
			++$month;
		} else {
			$month = ++$year*12;
		}

		$selected = '';
		if ($currentMonth == $month) {
			$selected = 'selected="selected"';
		}
		$str .= '<option value="'.$month.'" '.$selected.'>'.$helper->pluralMonths($month).'</option>';
	}

	return $str;
}

?>

<link rel="stylesheet" media="screen" href="http://<?php echo Config::getInstance()->default->hostname; ?>/style/admin_product.css" />
<!--[if lte IE 7]><link href="/style/ie.css" rel="stylesheet" type="text/css"><![endif]-->
<form enctype="multipart/form-data" method="post" action="">
  <div>

	<?php
	/**
	 * Translate some form errrors.
	 *
	 * @param string $key
	 * @param string $error
	 * @return string
	 */
	function _translate($key, $error)
	{
		$_translated = array(
			'isEmpty' => 'Поле обязательно для заполнения',
		);

		if (isset($_translated[$key])) {
			return $_translated[$key];
		}

		return $error;
	}

	$errors = $form->getMessages();
	foreach ($errors as $key => $error) {
		if (is_array($error)) {
			unset($errors[$key]);
		}

		if (is_array($error)) {
			foreach ($error as $k => $v) {
				$label = $form->getElement($key)->getLabel();
				$v = _translate($k, $v);
				$errors[$key][$k] = "$label -- $v";
			}
		} else {
			$errors[$key] = _translate($key, $error);
		}
	}

	if ($errors) {
		echo "<ul class='errors'>";
		foreach ($errors as $error) {
			if (is_array($error)) {
				foreach ($error as $k => $v) {
					echo "<li>$v</li>";
				}
			} else {
				echo "<li>$error</li>";
			}
		}
		echo "</ul>";
	}
	?>

	<fieldset>
		<legend>Популярные</legend>
	 <dl class="floater-5">
	<?php
		$rank = $form->getElement('rank');
		$rank->setAttrib('readonly','readonly');
		$rank->setAttrib('style','background: #EEE;');
		echo $rank;
	?>
	  </dl>
	  <dl class="floater-5">
		<?php echo $form->getElement('priority'); ?>
	  </dl>
	  <dl class="floater-5">
		<?php echo $form->getElement('price'); ?>
	  </dl>

	  <dl class="floater-5">
		<?php $rating = $form->getElement('rating');
			   $rating->setRequired(0);
				echo $rating;
		   ?>
	  </dl>
	  <dl class="floater-5">
	  <?php $votes_count = $form->getElement('votes_count');
			$votes_count->setRequired(0);
			echo $votes_count;
	  ?>
	  </dl>
	  <dl class="floater-5">
		<?php echo $form->getElement('count'); ?>
	  </dl>
	  <dl class="floater-5">
	   <?php $sales_count = $form->getElement('sales_count');
			  $sales_count->setRequired(0);
				echo $sales_count;
	   ?>
	  </dl>
	  <dl>
		<?php echo $form->getElement('tag2product'); ?>
	  </dl>
	 <dl >
		<?php echo $form->getElement('old_price'); ?>
	  </dl>
	 <dl>
		<?php //$old_price = $form->getElement('clean_price');
				//$old_price->setRequired(0);
				//echo $old_price;
		 ?>
	</dl>
	<dl>
		<?php $time_display_prices = $form->getElement('time_display_prices');
				$time_display_prices->setRequired(0);
				echo $time_display_prices;
		?>
	</dl>

	</fieldset>


	<fieldset>
	  <legend>Основные</legend>


	<dl class="floater-4">
	  <?php $e = $form->getElement('internal_id');
	  if ($e) $e->setAttrib('size', 15); echo $e; ?>
	</dl>
	<dl class="floater-4">
	  <?php echo $form->getElement('file_image'); ?>
	</dl>
	<div class="clearfix"></div>
	<dl  class="floater-4 floats" style='margin-top: 28px; margin-right: 40px;font-weight:bold;width:180px;'>
		<?php echo $form->getElement('manufacturer_warranty'); ?>
	</dl>

	<dl class="floater-4">
	  <?php echo $form->getElement('artikul'); ?>
	</dl>

	<dl class="floater-4">
	  <?php echo $form->getElement('days_end'); ?>
	</dl>
	<div class="clearfix"></div>

	<dl class="floater-2">
	  <?php echo $form->getElement('name'); ?>
	  <!--dt id="translated_url-label">
		<label for="translated_url" class="optional">Название страницы для URL</label>
	  </dt>
	  <dd id="translated_url-element">
		<input type="text" name="translated_url" id="translated_url" value="nabor_ukras_mobilnik_hanna_montana" maxlength="255" size="128">
	  </dd-->
	</dl>
	<dl class="floater-2">
	  <?php $brand = $form->getElement('brand_id');
			$brand->setRequired(1);
			echo $brand;
	  ?>
	</dl>

	<dl class="floater-4">
	  <?php $collection = $form->getElement('collection_id');
			$collection->setRequired(0);
			echo $collection;
	  ?>
	</dl>
	<div class="clearfix"></div>
	<dl class="floater-2">
	   <?php echo $form->getElement('country_id'); ?>
	</dl>
	<div class="clearfix"></div>

	<dl  class="floater-3">
	   <?php echo $form->getElement('product2product_category'); ?>
	</dl>
	  <div class="clearfix"></div>
	  <div style="padding-top: 20px;">
	  <dl class="floater-3">
		<label><b>Возраст от:</b></label>
		   <select id='age_from' name="age_from" style="width: 80px;">
				<option value=''>не важно</option>
				<option value='0' <?php if($productRow->getFromBorn()){echo 'selected="selected"';}?>>c рождения</option>
				<?php echo getMonthsByAge(12*20, $productRow->getAgeFrom()); ?>
			</select>
			<label><b>Возраст до:</b></label>
			<select id='age_to' name="age_to" style="width: 80px;">
				<option value='255'>не важно</option>
				<?php echo getMonthsByAge(12*20, $form->getValue('age_to')); ?>
			</select>
	  </dl>

	  <dl class="floater-3">
		<label><b>Пол:</b></label>
			  <!-- <span style="color: red; padding-left: 4px;">*</span>-->
			   <select style="width: 80px;" id="gender" name="gender">
				   <?php
					if($form->getValue('gender') == 0){
						echo "<option selected='selected' value='0'>Неважно</option>";
					}else{
						echo "<option value='0'>Неважно</option>";
					}
					if($form->getValue('gender') == 1){
						echo "<option selected='selected' value='1'>Мужской</option>";
					}else{
						echo "<option value='1'>Мужской</option>";
					}
					if($form->getValue('gender') == 2){
						echo "<option selected='selected' value='2'>Женский</option>";
					}else{
						echo "<option value='2'>Женский</option>";
					}
			   ?>
			   </select>
	  </dl>
	  </div>
	  <div class="clearfix"></div>
	<dl  class="floater-3">
	   <?php echo $form->getElement('full_desc'); ?>
	</dl>
	  <div class="clearfix"></div>

	  <dl class="floater-3">
		<?php echo $form->getElement('synonims'); ?>
	  </dl>


	  <div class="clearfix">

	  </div>
	  </fieldset>
    
	  <fieldset class="foto_ie" style="padding-left: 10px">
		<legend>Файлы</legend>
		<?php echo $form->getElement('photo_1'); ?> <?php echo $form->getElement('file_video'); ?> <?php echo $form->getElement('file_swf'); ?><?php echo $form->getElement('file_ny'); ?>
	  </fieldset>
		<fieldset>
		<legend>Отображать на промо-сайте со след вариантами</legend>
	<dl class="floater-5">
		<?php echo $form->getElement('ny_index'); ?>
	  </dl>
	<dl class="floater-5">
		<?php echo $form->getElement('ny_twohundred'); ?>
	  </dl>
	<dl class="floater-5">
		<?php echo $form->getElement('ny_top10_boy'); ?>
	  </dl>
	<dl class="floater-5">
		<?php echo $form->getElement('ny_top10_gerl'); ?>
	  </dl>

	<dl class="floater-5">
		<?php echo $form->getElement('ny_top10_baby'); ?>
	  </dl>
	<dl class="floater-5">
		<?php echo $form->getElement('ny_top10_active'); ?>
	  </dl>
	 </fieldset>
<!-- **************************************************************************-->
	<fieldset>
		<legend>Признаки</legend>
	<dl class="floater-5">
		<?php echo $form->getElement('is_hit'); ?>
	  </dl>
	<dl class="floater-5">
		<?php echo $form->getElement('is_new'); ?>
	  </dl>
	<dl class="floater-5">
		<?php echo $form->getElement('is_sale'); ?>
	  </dl>
	<dl class="floater-5">
		<?php echo $form->getElement('is_discout'); ?>
	  </dl>

	<dl class="floater-5">
		<?php echo $form->getElement('is_recommended'); ?>
	  </dl>
	<dl class="floater-5">
		<?php echo $form->getElement('is_brand'); ?>
	  </dl>
	 </fieldset>
<!-- ****************************************************************************-->

	<fieldset class="chek_ie">
	  <legend>Характеристики</legend>
	  <dl class="floater-5">
		<?php echo $form->getElement('weight'); ?>
	  </dl>
	  <dl class="floats topped" style="width: 140px; padding-top: 24px;">
		<?php echo $form->getElement('is_bulky'); ?>
	  </dl>

	  <dl class="floater-4">
		<?php echo $form->getElement('size'); ?>
	  </dl>
	  <dl class="floater-4">
		<?php echo $form->getElement('material'); ?>
	  </dl>
	  <dl class="floater-4">
		<?php echo $form->getElement('dimension'); ?>
	  </dl>
	  <dl class="floater-4">
		<?php echo $form->getElement('color'); ?>
	  </dl>
	  <div class="clearfix"></div>
	  <dl class="floater-4">
		<?php echo $form->getElement('file_certificate'); ?>
	  </dl>
	  <dl class="floater-4">
		<?php echo $form->getElement('file_rules'); ?>
	  </dl>
	  <dl class="floater-4">
		<?php
			if ($form->getValue('file_instruction')){
				echo "<br><input type='checkbox' name='del_instruction' value='".$form->getValue('file_instruction')."'> Удалить<br> прикрепленную ранее инструкцию";
			}
			else echo $form->getElement('file_instruction');
		 ?>

	  </dl>

	</fieldset>

	<fieldset>
	  <legend>Сопутствующие и похожие товары</legend>
	  <dl>
		<?php echo $form->getElement('alike'); ?>
	  </dl>
	  <dl>
		<?php echo $form->getElement('attendant'); ?>
	  </dl>
	  <dl>
		<?php echo $form->getElement('attendant_category'); ?>
	  </dl>
	</fieldset>
	<dl>
	  <?php echo $form->getElement('parent_id'); ?>
	  <?php $subproducts_count = $form->getElement('subproducts_count');
			$subproducts_count->setRequired(0);
			echo $subproducts_count;
	  ?>
	  <?php echo $form->getElement('internal_comment'); ?>
	  </dl>
	  <dl class="floats">
		<?php echo $form->getElement('is_active'); ?>
	  </dl>
	  <dl style="clear:both">
	  <dt id="submit-label">
		&nbsp;
	  </dt>
	  <dd id="submit-element">
		<input type="submit" name="submit" id="submit" value="Сохранить">
	  </dd>

	  <?php echo $form->getElement('crud_exit'); ?>
	</dl>
  </div>
</form>